<?php

namespace app\admin\model;

use think\Model;

class AdminRole extends Model {

    protected $resultSetType = 'collection';

    /**
     * 获取缓存数据
     * @return type
     */
    public function getCache() {
        $data = null; //cache('role');
        if ($data) {
            return $data;
        }
        return $this->setCache();
    }

    /**
     * 设置缓存数据
     * @return type
     */
    public function setCache() {
        $data = $this->select()->toArray();
        $role = array_column($data, null, 'id');
        cache('role', $role);
        return $role;
    }

}
